#ifndef _ARP_H
#define _ARP_H

#include <vector>

#define HAVE_REMOTE

#define ETH_IP			0x0800
#define ETH_ARP			0x0806
#define ARP_REQUEST		0x0001
#define ARP_REPLY		0x0002
#define ARP_HARDWARE	0x0001

#define ARP_PACKET_SIZE 0x003C

#pragma pack(push, 1)

typedef struct ethdr
{
	unsigned char   eh_dst[6];
	unsigned char   eh_src[6];
	unsigned short  eh_type;
} ETHDR, *PETHDR;

typedef struct arphdr
{
	unsigned short  arp_hdr;
	unsigned short  arp_pro;
	unsigned char   arp_hln;
	unsigned char   arp_pln;
	unsigned short  arp_opt;
	unsigned char   arp_sha[6];
	unsigned long   arp_spa;
	unsigned char   arp_tha[6];
	unsigned long   arp_tpa;
} ARPHDR, *PARPHDR;

typedef struct arpPacket
{
	ETHDR ehhdr;
	ARPHDR arphdr;
} ARPPACKET, *PARPPACKET;

typedef struct handParam
{
	bool is_recv;
	int ui_ip_addr;
	char mac_addr[6];
} HANDPARAM;

#pragma pack(pop)

int init_arp_packet(ARPPACKET *arp_packet, unsigned int packet_size, 
					unsigned int mac_address_len, unsigned int ip_address_len, 
					unsigned char *send_mac_address, unsigned int send_ip_address, 
					unsigned char *recv_mac_address, unsigned int recv_ip_address);

int get_mac_address_by_ip(unsigned int ui_target_ip_address, unsigned char *target_mac_address, unsigned int target_mac_address_len, int inum);

void arp_atack(unsigned int ui_ip_addr, int inum);

void arp_atack(std::vector<unsigned int> ui_ip_addr, int inum);

void arp_atack2(unsigned int ui_ip_addr, int inum);

void arp_atack2(std::vector<unsigned int> ui_ip_addr, int inum);

#endif
